host: <%= p("nats.listen_address") %>
port: <%= p("nats.port") %>
<% if p('nats.enable_metrics_endpoint') %>
http: localhost:8222
<% end %>
logtime: true

log_file: /var/vcap/sys/log/nats/nats.log

authorization {
  users = [
    {
      user: "C=USA, O=Cloud Foundry, CN=default.director.bosh-internal"
      permissions: {
        publish: [ "agent.*", "hm.director.alert" ]
        subscribe: [ "director.>" ]
      }
    },
    {
      user: "C=USA, O=Cloud Foundry, CN=default.hm.bosh-internal"
      permissions: {
        publish: []
        subscribe: [
          "hm.agent.heartbeat.*",
          "hm.agent.alert.*",
          "hm.agent.shutdown.*",
          "hm.director.alert"
       ]
      }
    }
  ]
}

tls {
  cert_file:          "/var/vcap/jobs/nats/config/nats_server_certificate.pem"
  key_file:           "/var/vcap/jobs/nats/config/nats_server_private_key"
  ca_file:            "/var/vcap/jobs/nats/config/nats_client_ca.pem"
  verify_and_map:     true
  timeout:            <%= p('nats.tls.timeout') %>
}

ping_interval: <%= p('nats.ping_interval') %>
ping_max: <%= p('nats.ping_max_outstanding') %>
max_payload: <%= (1048576 * p('nats.max_payload_mb').to_f).to_i %>

include ../../../data/nats/auth.json
